<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	

	<title>欢迎乘坐G4有轨电车</title>
	<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/car/train.css">

	<!--[if lt IE 9]>
	  <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	  <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>

	<body>
		<div class="wrapper index-wrapper">
			<div class="car-top animated slideUpRetourn">
				<img src="{$_C.hy_path}images/car/car-bg.png" alt="">
				<div class="car-top-info">
					<div class="tx_outbox">
						<div class="out_box">
							<img src="{$_C.hy_path}images/car/1.png" alt="">
						</div>
						<div class="touxiamg">
							<img src="{$info.headimgurl}" alt="">
						</div>
						<p class="cl-f-grey">{$info.name}</p>
					</div>
					<div class="title">
						<img src="{$_C.hy_path}images/car/car-title.png" alt="">
						<p class="cl-f-grey">今天是{$md}<span class="day">星期{$w}</span></p>
					</div>
				</div>
			</div>
			<div class="car-choose">
	        	<div class="btqian" onclick="ajax_prize()">
	        		<img class="animated flipInX delay15" src='{$_C.hy_path}images/car/btqian.png'/>
	        	</div>
	        	<div class="btjiang">
	        		<img class="animated flipInX delay15" src='{$_C.hy_path}images/car/btjiang.png'/>
	        	</div>
			</div>
			<div class="cheng">
				<img src="{$_C.hy_path}images/car/jiang.png" />
				<div class="tanc_c" id="tanc_c" onclick="hiddenImg()"></div>
				<div class="cheng-btn" onclick="try_card()"></div>
			</div>
			<div class="cheng2">
				<img src="{$_C.hy_path}images/car/jiangno.png" />
				<div class="tanc_c" id="tanc_c" onclick="hiddenImg2()"></div>
				
			</div>
		</div>
		<script src="{$_C.hy_path}/js/car/jquery-1.11.2.min.js"></script>
		<script src="{$_C.hy_path}/js/car/toast.js"></script>
		{include file="../Common/g4-share-train.html"}
		<script>
		function hiddenImg(){
			$('.cheng').fadeOut();
		}
		function hiddenImg2(){
			$('.cheng2').fadeOut();
		}
	function showimg(){
			$('.cheng').fadeIn();
		}
	function showimg2(){
		$('.cheng2').fadeIn();
	}
	$('.btjiang').click(function(){
			self.location='/ws/index.php?g=mobile&m=car&a=jiang'
		})
	$('.cheng-btn').click(function(){
			// self.location='car-jiang.html'
		})
	$(document).ready(function () {
	});
	
	
	var prize_user_id = ''; 
	
	var is_get = false;
	
	var is_prize = false;
	
	var is_try = false;
	
	 
		
	
	
    function ajax_prize()
	  {
		
    	
		  var url = "index.php?g=mobile&m=car&a=ajaxPrize";
			
			$.post(url,{ card_type:1 },function(data){
				 
		         if(data.error==1){
		        	 
		        	 showimg();
		        	 
		        	 prize_user_id = data.data.user_id;
		        
		        	
		         }else{
		        	 showimg2();
		        	 
		        	 prize_user_id = 0;
		        	
		         }
				 
			},"json");
	  
  	
	  }
    	
    
    
	  function try_card()
	  {
		
		  if(is_prize == true)
		  {
		  	warn("你已领取过奖品了");
		  	return;
		  }
		  
		  if(is_get == true)
		  {
		  	warn("奖品领取中");
		  	return;
		  }
		  
		  is_get = true;
		  
		  var url = "index.php?g=mobile&m=car&a=ajaxCard";

		  var data = {
				  id:prize_user_id
		  };
		 
			$.post(url,data,function(cardlist){
				is_get = false;
				
				 wx.addCard({
		              cardList: cardlist,
		              success: function (res) {
		            	  
		            	  is_get = true;
		            	  
		            	  is_prize = true;
		            	  
		            	  get_card(prize_user_id);  
		              }
		            });
				 
				 
				 
			},"json");
    	  
      	
	  }
	  
	  
	  //领取卡券后异步回调
	  function get_card(id)
	  {
			  
		  var url = "index.php?g=mobile&m=car&a=getCard";
			
		  var data = {
				  id:id
		  }
			$.post(url,data,function(res){
				//showMsg("领取成功。");
				
				//window.location.href="index.php?g=mobile&m=car&a=shake";
				//document.getElementById('mcover').style.display='block';
				
			},"text");
    	  
      
	  }
	  
		</script>
	</body>
</html>
